package com.dibang.app.operation.control.impl;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.dibang.app.R;
import com.dibang.app.adapter.PeerAdapter;
import com.dibang.app.bean.PeerItem;
import com.dibang.app.mvp.abs.AbsControl;
import com.dibang.app.operation.control.abs.PeerControl;
import com.dibang.app.operation.model.abs.PeerModel;
import com.dibang.app.operation.presenter.abs.PeerPresenter;
import com.dibang.app.operation.provider.PeerProImpl;
import com.dibang.app.operation.view.abs.PeerView;
import com.dibang.app.view.RxContentRecyclerView;
import com.dibang.app.view.ViewHelper;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import am.widget.stateframelayout.StateFrameLayout;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by wxl on 2019/7/24.
 *
 */

public class PeerControlImpl extends AbsControl<PeerView,PeerPresenter,PeerModel,PeerProImpl> implements PeerControl {

    @BindView(R.id.main_peer_list_view)
    RxContentRecyclerView peerView;

    @BindView(R.id.main_peer_list_state_view)
    StateFrameLayout stateFrameLayout;

    @BindView(R.id.main_peer_list_smart_view)
    SmartRefreshLayout smartRefreshLayout;

    public PeerControlImpl(@NonNull View targetView) {
        super(targetView);
        ButterKnife.bind(this,targetView);
        getView().setPeerViewLinerLayoutManager(peerView);
    }


    @Override
    public void setPeerViewLinerLayoutManagerChanged(@NonNull RecyclerView peerView) {
        PeerAdapter adapter;
        peerView.setAdapter(adapter = new PeerAdapter(R.layout.item_peer_layout, PeerItem.get()));
        ViewHelper.setStateSimpleEmptyView(stateFrameLayout,"没有符合当前条件的线路。");
        ViewHelper.setStateSimpleLoadingView(stateFrameLayout);
        ViewHelper.setStateSimpleErrorView(stateFrameLayout, "请求发生了错误\n点击空白处重新请求。", new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
        adapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                switch (view.getId()) {
                    case R.id.item_peer_status_btn_view:

                        break;
                }
            }
        });
    }
}
